package etr.bk.gui.lpan;

import etr.bk.gui.*;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;

public class RenderListPan implements ListCellRenderer<Object>
{	
	
	private boolean allowSelectedMode ;
	
	private PictPan oneSelectedItem = null;
	
	
	public RenderListPan()
	{
		this.allowSelectedMode = true;
	}
	

	public Component getListCellRendererComponent(JList<?> list,
												  Object obj,
												  int arg2, 
												  boolean isSelected, 
												  boolean arg4)
	{
		boolean realSelect = isSelected && this.allowSelectedMode;
		
		
		//PictPan pan = (PictPan) obj;
		//pan.setSelect(realSelect, list);
		
		PictPan pan = (PictPan) obj;
		
		if (!allowSelectedMode){
		//	pan = this.oneSelectedItem;
			//this.oneSelectedItem.setSelect(true, list);
			if (pan.equals(oneSelectedItem))pan.setSelect(true, list);
			else pan.setSelect(false, list);
		}
		else {
			pan.setSelect(realSelect, list);
		}
		
		return pan;
	}
		
	public void setAllowSelectedMode(boolean allowSelectedMode)	{
		this.allowSelectedMode = allowSelectedMode;
	}
	
	public void setOneSelItem(PictPan oneItem){
		this.oneSelectedItem = oneItem;
	}
}


